<?php echo $documentForm->renderGlobalErrors()?>
<?php echo $paymentForm->renderGlobalErrors()?>
<?php echo $documentForm['document_iden']?>
<?php echo $documentForm['_csrf_token']?>
<?php echo $paymentForm['payment_iden']?>
<?php echo $paymentForm['customer_iden']?>
<?php echo $paymentForm['transaction_type']?>
<?php echo $paymentForm['_csrf_token']?>
<table>
  <tr>
    <th class="field"><?php echo $documentForm['owner_iden']->renderLabel()?></th>
    <td class="field">
      <?php echo $documentForm['owner_iden']->renderError()?>
      <?php echo $documentForm['owner_iden']?>
    </td>
  </tr>
  <tr>
    <th class="field"><?php echo $documentForm['counter_code']->renderLabel()?></th>
    <td class="field">
      <?php echo $documentForm['counter_code']->renderError()?>
      <?php echo $documentForm['counter_code']?>
    </td>
  </tr>
  <tr>
    <th class="field"><?php echo $paymentForm['payment_type']->renderLabel()?></th>
    <td>
      <?php echo $paymentForm['payment_type']?>
      <?php echo $paymentForm['payment_number']->renderError()?>
      <?php echo $paymentForm['payment_number']?>
    </td>
  </tr>
  <tr>
    <th class="field"><?php echo $documentForm['document_date']->renderLabel()?></th>
    <td>
      <?php echo $documentForm['document_date']->renderError()?>
      <?php echo $documentForm['document_date']?>
    </td>
  </tr>
  <tr>
    <th class="field"><?php echo $paymentForm['remarks']->renderLabel()?></th>
    <td>
      <?php echo $paymentForm['remarks']->renderError()?>
      <?php echo $paymentForm['remarks']?>
    </td>
  </tr>
  <?php if($transaction_type=='CASH'):?>
    <tr>
      <th class="field"><?php echo $paymentForm['cash']->renderLabel()?></th>
      <td>
        <?php echo $paymentForm['cash']->renderError()?>
        <?php echo $paymentForm['cash']?>
        [<?php echo $paymentForm->getObject()->getCash()?>]
      </td>
    </tr>
  <?php endif;?>
</table>


<script language="javascript">
  $(document).ready(function(){
    $('#payment_payment_number').blur(function(){
      $.getJSON(
        'payment/checkId',
        {
          "payment_iden":$('#payment_payment_iden').val(),
          "payment_type":$('#payment_payment_type').val(),
          "payment_number":$('#payment_payment_number').val(),
        },
        function(data){
          if(data.count > 0){
            payment_id = $('#payment_payment_type').val()+'-'+$('#payment_payment_number').val();
            alert(payment_id+' already exists.');
          }
        }
      );
    });
  });
</script>